home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 6⁄1⁄90 / 0132-C++ Library bug-May90 < prev    next >
Encoding:
Text File  |  1990-06-01  |  1.9 KB  |  69 lines  |  [TEXT/GEOL]

  1. Item    8208550                         31-May-90        00:30PDT
  2.  
  3. From:   D5000                           Succession, Eric Brewer,PRT
  4.  
  5. To:     MACDTS                          Macintosh Developer Tech Supt
  6.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  7.         CPLUS.DEV$                      C++ Interest List--Developers
  8.  
  9. Sub:    C++ Library bug
  10.  
  11. Hi,
  12.  
  13. The following code demonstrates a bug with the C++ runtime library for 3.1b1
  14. version of the C++ compiler.
  15.     #include <FStream.h>
  16.     #include <IOManip.h>
  17.     #include <IOStream.h>
  18.     #include <StdIO.h>
  19.     #include <StdLib.h>
  20.  
  21.  
  22.     main(int argc, char *argv[])
  23.     {
  24.         if (argc < 2)
  25.         {
  26.             cerr << "Usage: " << argv[0] << " input_file" << endl;
  27.             exit (1);
  28.         }
  29.  
  30.  
  31.         ifstream    input (argv[1]);
  32.         if (!input)
  33.         {
  34.             cerr << "Could not open " << argv[1] << " for input." << endl;
  35.             exit (1);
  36.         }
  37.  
  38.  
  39.         char        line[256];
  40.         while (input.good ())
  41.         {
  42.             input.getline (line, sizeof line);
  43.             cout << "Line is '" << line << "'" << endl;
  44.         }
  45.     }
  46. The above code should copy every line of a given file to stdout with the string
  47. "Line is'" preceding each line, and "'" terminating each line.  This happens
  48. correctly as long as the file ends with a newline.  If a file does not end with
  49. a newline, the last line will not be output (e.g. lost).
  50.  
  51. I compiled and linked the file with the following commands:
  52.   CPlus Bug.cp -o Bug.cp.o -i {Boot}MPW:Interfaces:CIncludes:
  53.   Delete -i f
  54.   Link Bug.cp.o -o Bug ∂
  55.    -c "Eric" -t "MPST" ∂
  56.    "{CLibraries}"CPlusLib.o ∂
  57.    "{CLibraries}"CRuntime.o ∂
  58.    "{CLibraries}"StdCLib.o ∂
  59.    "{CLibraries}"CInterface.o ∂
  60.    "{Libraries}"Interface.o
  61.  
  62. Has anyone else run into this problem?  Is there a reasonable work around?
  63.  
  64.  
  65. Thanks,
  66. Eric T. Brewer
  67. D5000
  68.  
  69.